/* eslint-disable @typescript-eslint/no-explicit-any */
import React, { useContext, useEffect } from 'react';
import AddName from './components/addName';
import { storeContext } from '../stories';
import { useHistory } from 'react-router';
const BApp: React.FC<any> = () => {
    const { state } = useContext<any>(storeContext);
    const history = useHistory()
    useEffect(() => {
        console.log('我加载更新了,BApp!');
    });
    const handleRouteChange = () => {
        // useHistory
        history.push("/")
    };
    return (
        <>
            <span>{state.user.name}</span>
            <button onClick={handleRouteChange}>返回首页</button>
        </>
    );
};
const ReduxApp: React.FC = () => {
    const { dispatch } = useContext<any>(storeContext);
    const AddNameDemo = React.memo(AddName)
    useEffect(() => {
        
        return () => {
            console.log("object")
            dispatch({type:'CLEARDATA'})
        }
    },[])
    return (
        <div>
            <AddNameDemo />
            <br />
            <BApp />
        </div>
    );
};
export default ReduxApp;
